﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;

namespace SLMNG
{
    public partial class M_dlgSelectProduct : DevExpress.XtraEditors.XtraForm
    {
        public M_dlgSelectProduct()
        {
            InitializeComponent();
        }

        public DataTable dt = new DataTable();

        private void M_dlgSelectProduct_Load(object sender, EventArgs e)
        {
            string[] arg = new string[] { "@ProductID" };
            object[] obj = new object[] { DBNull.Value };
            DataSet ds = CatalogueBase.GetData("usp_Products_Select", arg, obj);
            gridOverView.DataSource = ds.Tables[0];
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            dt = ((DataTable)gridOverView.DataSource).Clone();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            for (int i = 0; i < gridView1.SelectedRowsCount; i++)
            {
                if(gridView1.GetSelectedRows()[i] >= 0)
                    dt.ImportRow(gridView1.GetDataRow(gridView1.GetSelectedRows()[i]));
            }
            this.Dispose();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Dispose();
        }
    }
}
